define(function (require, exports, module) {
        exports.init = function (element, cb) {
                var basic=require('basic');
                var jsonAPI = require('json-api');
                require('../js/modules/md5.js');
                $("#title").text('同户登录');
                reg = /^[1][358]\d{9}$/; //验证手机号码

                var mobile=getQueryParam('mobile');
                if(mobile&&mobile!='')
                {
                        $("#mobile").val(mobile);
                        $("#password").focus();
                }

                defineModule({
                        login: function () {
                                var phone = $("#mobile").val();
                                if (!reg.test(phone)) {
                                        $spa.showErrorMsg('请输入正确的手机号!');
                                        return false;
                                }

                                var password = $("#password").val();
                                if (password.length < 6) {
                                        $spa.showErrorMsg('请输入有效的密码!');
                                        return false;
                                }
                                var param = {
                                        "mobile": phone, //手机号
                                        "password": $.md5(password)
                                }

                                jsonAPI.restful('/api/user/login', param, function (err, result) {
                                        if (jsonAPI.handleErrors(err, result)) {
                                                basic.saveUserMoblie(phone);
                                                if(app.cache('refer'))
                                                {
                                                        window.hashTo(app.cache('refer'));
                                                }
                                                else
                                                        window.hashTo('#home');
                                        }
                                });
                        }
                })


                cb && cb();
        };
});